<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>社会关系信息增加</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="mini-fit">
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
        <input name="priNum" id="priNum" class="mini-hidden" style="width: 100%" readonly />

        <form id="form3" method="post" style="margin-left: 10px;">
            <span style="font-size:16px; font-family: 宋体;line-height: 30px;font-weight: bold">配偶、父母或其他:</span>

            <div style="width:1250px;">
                <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                    <table style="width:100%;">
                        <tr>
                            <td style="width:100%;">
                                <a class="mini-button" iconCls="fa fa-plus" onclick="addSr()">增加</a>
                                <a class="mini-button" iconCls="fa fa-edit" onclick="editSr()">编辑</a>
                                <a class="mini-button" iconCls="fa-trash-o" onclick="removeSr()">删除</a>
                            </td>

                        </tr>
                    </table>
                </div>
            </div>
            <div id="grid3" class="mini-datagrid" style="width:1250px;height:200px;" sizeList="[5]" pageSize="5"
                 url="/azbj/social/srlist" idField="id"
                 selectOnLoad="true">
                <div property="columns">
                    <div field="thename" width="35" headerAlign="center" align="center">姓名</div>
                    <div field="relation" width="35" headerAlign="center" align="center">关系</div>
                    <div field="age" width="35" headerAlign="center" align="center">出生日期</div>
                    <div field="danwei" width="35" headerAlign="center" align="center">工作单位</div>
                    <div field="addr" width="40" headerAlign="center" align="center">家庭住址</div>
                    <div field="phone" width="35" headerAlign="center" align="center">手机号码</div>
                    <div field="tel" width="35" headerAlign="center" align="center">固定电话</div>
                </div>
            </div>
        </form>
        <hr />
        <form id="form1" method="post" style="margin-left: 10px;">
            <span style="font-size:16px; font-family: 宋体;line-height: 30px;font-weight: bold;margin-bottom: 10px">未成年子女信息:</span>
            <div style="width:1250px;">
                <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                    <table style="width:100%;">
                        <tr>
                            <td style="width:100%;">
                                <a class="mini-button" iconCls="fa fa-plus" onclick="addNoAdult()">增加</a>
                                <a class="mini-button" iconCls="fa fa-edit" onclick="editNoAdult()">编辑</a>
                                <a class="mini-button" iconCls="fa-trash-o" onclick="removeNoAdult()">删除</a>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>

            <div id="grid1" class="mini-datagrid" style="width:1250px;height:210px;" sizeList="[5]" pageSize="5"
                 url="/azbj/noadult/list"
            >
                <div property="columns">
                    <div field="name" width="35" headerAlign="center" align="center">姓名</div>
                    <div field="sex" width="35" headerAlign="center" align="center">性别</div>
                    <div field="age" width="35" headerAlign="center" align="center">出生日期</div>
                    <div field="kunnan" width="35" headerAlign="center" align="center">生活困难程度</div>
                    <div field="liulang" width="35" headerAlign="center" align="center">流浪社会</div>
                    <div field="bfnum" width="50" headerAlign="center" align="center">帮扶活动开展次数</div>
                    <div field="jianhuren" width="35" headerAlign="center" align="center">监护人</div>
                    <div field="shixue" width="35" headerAlign="center" align="center">失学</div>
                    <div field="fanzui" width="35" headerAlign="center" align="center">违法行为</div>
                    <div field="znsfid" width="50" headerAlign="center" align="center">身份证号</div>
                    <div field="hujidi" width="50" headerAlign="center" align="center">户籍地</div>
                    <div field="juzhudi" width="50" headerAlign="center" align="center">居住地址</div>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    mini.parse();
    var form1 = new mini.Form("form1");
    var grid1 = mini.get("grid1");
    var grid3 = mini.get("grid3");
    var priNum = mini.get("priNum");

    function addNoAdult() {
        var prinum = priNum.getValue();
        if (prinum == "") {
            mini.alert("请先保存基本信息");
        } else {
            mini.open({
                url: "/azbj/social-relations/noadultadd/view?prinum=" + prinum,
                title: "新增未成年子女信息", width: 1000, height: 500,
                onload: function () {
                },
                ondestroy: function (action) {
                    if (typeof callback === "function") {
                        var options = {};
                        for (var i = 6; i < args.length; i++) {
                            options[i - 6] = args[i];
                        }
                        if (options.length == 0) {
                            callback(action);
                        } else {
                            callback(action, options);
                        }
                    }
                    grid1.reload();
                }
            });
        }
    }

    function editNoAdult() {
        var row = grid1.getSelected();
        if (row) {
            mini.open({
                url: "/azbj/social-relations/noadultedit/view",
                title: "编辑未成年子女信息", width: 1000, height: 500,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = {action: "edit", id: row.id};
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid1.reload();
                }
            });

        } else {
            mini.alert("请选中一条记录");
        }
    }

    function removeNoAdult() {
        var row = grid1.getSelected();
        var url = "/azbj/social/noadultremove";
        if (row) {
            mini.confirm("确定删除选中记录？",
                "确定？",
                function (action) {
                    if (action == "ok") {
                        $.ajax({
                            url: url,
                            type: 'POST',
                            cache: false,
                            async: false,
                            data: {id: row.id},
                            success: function (text) {
                                mini.alert("操作成功!");
                                grid1.reload();
                            }, error: function () {
                                mini.alert("操作失败!");
                            }
                        });
                    }
                });
        } else {
            mini.alert("请选中一条记录");
        }
    }

    function addSr() {
        var prinum = priNum.getValue();
        if (prinum == "") {
            mini.alert("请先保存基本信息");
        } else {
            mini.open({
                //targetWindow: window,
                url: "/azbj/social-relations/sr/view?prinum=" + prinum,
                title: "新增-配偶、父母或其他", width: 1000, height: 500,
                onload: function () {
                },
                ondestroy: function (action) {
                    grid3.reload();
                }
            });
        }
    }

    function editSr() {
        var row = grid3.getSelected();
        if (row) {
            mini.open({
                url: "/azbj/social-relations/sredit/view?prinum=" + priNum.getValue(),
                title: "编辑-配偶、父母或其他信息", width: 1000, height: 500,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = {action: "edit", id: row.id};
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid3.reload();
                }
            });

        } else {
            mini.alert("请选中一条记录");
        }
    }

    function removeSr() {
        var row = grid3.getSelected();
        var url = "/azbj/social/srinforemove";
        if (row) {
            mini.confirm("确定删除选中记录？",
                "确定？",
                function (action) {
                    if (action == "ok") {
                        $.ajax({
                            url: url,
                            type: 'POST',
                            cache: false,
                            async: false,
                            data: {id: row.id, priNum: row.priNum},
                            success: function (text) {
                                mini.alert("操作成功!");
                                grid3.reload();
                            }, error: function () {
                                mini.alert("操作失败!");
                            }
                        });
                    }
                });
        } else {
            mini.alert("请选中一条记录");
        }
    }

    window.onload = function () {
        priNum.setValue(${priNum!''});
        if (priNum.getValue() == "") {
            mini.alert("请先保存基本信息");
        } else {
            grid1.load({querykey: priNum.getValue()});
            grid3.load({priNum: priNum.getValue()});
        }
    }
</script>
</body>
</html>